package com.sxkiler.demo.test.data;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;

import java.math.BigDecimal;

//"fid","客户名称","片区","续费月","应签日期","注册时间","首次下单时间","租赁年限","当前在用项目数","登陆次数","总提单数","已关闭提单","未关闭提单"
public class UserHealthVo {
    private void init(){
        this.id = "id";
        this.customerName = "客户名称";
        this.areaName = "片区";
        this.payMonth = "续费月";
        this.endDate = "应签日期";
        this.registerDate = "注册日期";
        this.orderDate = "首次下单日期";
        this.rentYear = "租赁期限";
        this.projectCount = "在用项目数";
        this.isLogin = "7天内是否登录";
        this.isOper = "7天内是否操作";
        this.allBillCount = "总提单数";
        this.uncloseBillCount = "未关闭提单";
    }
    public UserHealthVo(){
        init();
    }
    public UserHealthVo(String []values){
        if(values.length==12){
            this.id = UserHealthCheck.getValueString(values[0]);
            this.customerName = UserHealthCheck.getValueString(values[1]);
            this.areaName = UserHealthCheck.getValueString(values[2]);
            this.payMonth = UserHealthCheck.getValueString(values[3]);
            this.endDate = UserHealthCheck.getValueString(values[4]);
            this.registerDate = UserHealthCheck.getValueString(values[5]);
            this.orderDate = UserHealthCheck.getValueString(values[6]);
            long rentDay = DateUtil.between(DateUtil.parseDate(this.endDate),DateUtil.parseDate(this.orderDate), DateUnit.DAY);
            this.rentYear = BigDecimal.valueOf(rentDay).divide(new BigDecimal(365.0),0,BigDecimal.ROUND_HALF_UP).toString();
            this.projectCount = UserHealthCheck.getValueString(values[8]);
//            this.loginCount = Integer.parseInt(UserHealthCheck.getValueString(values[9],"0"));
//            if(this.loginCount>0){
//                isLogin = "是";
//            }else{
//                isLogin = "否";
//            }
            this.allBillCount = ""+Integer.parseInt(UserHealthCheck.getValueString(values[9],"0"));
//            this.closeBillCount = ""+Integer.parseInt(UserHealthCheck.getValueString(values[10],"0"));
            this.uncloseBillCount = ""+Integer.parseInt(UserHealthCheck.getValueString(values[11],"0"));
        }else{
            init();
        }
    }
    String id;
    String customerName;
    String areaName;
    String payMonth;
    String endDate;
    String registerDate;
    String orderDate;
    String rentYear;
    String projectCount;
    Integer loginCount;
    String isLogin;
    String allBillCount;
    String closeBillCount;
    String uncloseBillCount;
    Integer operCount;
    String isOper;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getAreaName() {
        return areaName;
    }

    public void setAreaName(String areaName) {
        this.areaName = areaName;
    }

    public String getPayMonth() {
        return payMonth;
    }

    public void setPayMonth(String payMonth) {
        this.payMonth = payMonth;
    }

    public String getEndDate() {
        return endDate;
    }

    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

    public String getRegisterDate() {
        return registerDate;
    }

    public void setRegisterDate(String registerDate) {
        this.registerDate = registerDate;
    }

    public String getOrderDate() {
        return orderDate;
    }

    public void setOrderDate(String orderDate) {
        this.orderDate = orderDate;
    }

    public String getRentYear() {
        return rentYear;
    }

    public void setRentYear(String rentYear) {
        this.rentYear = rentYear;
    }

    public String getProjectCount() {
        return projectCount;
    }

    public void setProjectCount(String projectCount) {
        this.projectCount = projectCount;
    }

    public Integer getLoginCount() {
        return loginCount;
    }

    public void setLoginCount(Integer loginCount) {
        this.loginCount = loginCount;
        if(loginCount>0){
            isLogin = "是";
        }else{
            isLogin = "否";
        }
    }

    public String getIsLogin() {
        return isLogin;
    }

    public void setIsLogin(String isLogin) {
        this.isLogin = isLogin;
    }

    public String getAllBillCount() {
        return allBillCount;
    }

    public void setAllBillCount(String allBillCount) {
        this.allBillCount = allBillCount;
    }

    public String getCloseBillCount() {
        return closeBillCount;
    }

    public void setCloseBillCount(String closeBillCount) {
        this.closeBillCount = closeBillCount;
    }

    public String getUncloseBillCount() {
        return uncloseBillCount;
    }

    public void setUncloseBillCount(String uncloseBillCount) {
        this.uncloseBillCount = uncloseBillCount;
    }

    public Integer getOperCount() {
        return operCount;
    }

    public void setOperCount(Integer operCount) {
        this.operCount = operCount;
    }

    public String getIsOper() {
        return isOper;
    }

    public void setIsOper(String isOper) {
        this.isOper = isOper;
    }
//    String [] titles = new String[]{"fid","客户名称","片区","续费月","应签日期","注册时间","首次下单时间","租赁年限","当前在用项目数","登陆次数","总提单数","已关闭提单","未关闭提单"};
    @Override
    public String toString() {
        return id
               +"," + customerName
               +"," + areaName
               +"," + payMonth
               +"," + endDate
               +"," + registerDate
               +"," + orderDate
               +"," + rentYear
               +"," + projectCount
               +"," + isLogin
               +"," + isOper
               +"," + uncloseBillCount
               +"," + allBillCount
                ;
    }
}
